﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Rmlife.Common;
namespace JqueryForm.handler
{
    /// <summary>
    /// Handler 的摘要说明
    /// </summary>
    public class Handler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            string act = context.Request.QueryString["act"]; // Common.Utils.WebUtils.GetString("act").ToString();
            switch (act)
            {
                case "PostReply": PostReply(context); break;
                default: break;
            }
        }
        public void PostReply(HttpContext context)
        {
            Result obj = new Result();
            obj.name = context.Request.Form["rname"];
            obj.pass = context.Request.Form["rpassport"];
            obj.reply = context.Request.Form["scontent"];
            #region "附件"
            HttpPostedFile file = context.Request.Files["postfile"];
            string jsonStr = string.Empty;
            if (file != null)
            {
                //得到今天允许用户上传的附件总大小(字节)
                obj.filename= file.FileName;
            }
            string strjson= JsonHelp<Result>.ToJsonString(obj);
            context.Response.Write(strjson);
            #endregion

        }

        public class Result
        {
           public string name { get; set; }
           public string pass { get; set; }
           public string reply { get; set; }
           public string filename { get; set; }
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}